function parseQuery(param) {
  if (!param || typeof param !== 'string') return null;
  var obj = {};
  var searchRegExp = /(?:^\?|&)(?:from=)([^&]*)(?:&|$)/;
  var searchFromValue = param.match(/(?:^\?|&)(?:from=)([^&]*)(?:&|$)/);
  if (searchFromValue) {
    return searchFromValue[1];
  }
  return null;
}
// 获取保存的公司名称
var companyName = window.localStorage.getItem('companyName');
// 获取传递过来的参数
var search = window.location.search;
var from = parseQuery(search);
if (from === 'myCompany') {
  // 从我的公司进入
  // 此处需要先判断用户是否登录过了，如果没有登录过则需要跳转到注册页面
  if (!companyName) {
    window.location.href = './guideRegister.html'+ search;
  }
} else {
  // 从使用指引进入
  if (!companyName) {
    window.location.href = './useGuide.html'+search;
  }
}
var cn = document.querySelector('#companyName');
var logout = document.querySelector('#loginout');
if (companyName) {
  cn.innerText = companyName;
} else {
  cn.innerText = '';
}
logout.addEventListener('click', function() {
  window.localStorage.removeItem('companyName');
  window.localStorage.removeItem('companyId');
  window.location.href = './useGuide.html';
});